//
//  HLBaseSessionViewController.h
//  YueYue
//
//  Created by hulu001 on 2023/6/13.
//

#import "HLViewController.h"
#import "HLIMInputViewProtocol.h"
#import "HLIMMessageCellProtocol.h"
#import "HLIMSessionConfig.h"
#import "HLChatKit.h"
#import "NIMMessage+RichTip.h"
#import "HLIMKitAudioCenter.h"
#import "HLIMKitTitleView.h"
#import "HLIMKitLeftBarView.h"
#import <NIMSDK/NIMSDK.h>

NS_ASSUME_NONNULL_BEGIN

@interface HLBaseSessionViewController : HLViewController<NIMChatManagerDelegate, NIMMediaManagerDelegate,NIMSystemNotificationManagerDelegate, NIMConversationManagerDelegate, HLIMKitInputViewActionDelegate, HLIMKitInputViewConfig, HLIMMessageCellProtocol, HLIMKitSessionInteractorDelegate>

@property (nonatomic, strong) HLIMKitTitleView *imTitleView;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) id<HLIMKitInputView> sessionInputView;
@property (nonatomic, strong) NIMSession *session;
@property (nonatomic, strong) NIMMessage *messageForMenu;
@property (nonatomic, weak)   id<HLIMKitSessionInteractor> interactor;

- (instancetype)initWithSession:(NIMSession *)session;

#pragma mark - 监听APP生命周期

/// APP 已经进入后台
- (void)appDidEnterBack;
/// APP 将要挂起
- (void)appWillResignActive;
/// APP 将要恢复前台活跃状态
- (void)appWillEnterForeground;

#pragma mark - 界面

/// 收否禁用输入面板 YES禁用 NO不禁止
@property (assign, nonatomic) BOOL disableInputView;


/// 刷新消息
- (void)refreshMessages;
- (void)loadNewMessgaes;

/// 结束下拉刷新 获取历史消息的刷新
- (void)endRefresh;

- (void)markRead;

- (id<HLIMSessionConfig, HLIMKitInputViewConfig>)sessionConfig;
// 配置
- (void)setupConfigurator;

- (NSArray *)menusItems:(NIMMessage *)message;

- (void)refreshBackgroundImage:(UIImage *)image url:(NSString *)url;

- (void)setupTableView;
- (void)changeCustomHeight:(NSInteger)height;

// 底部view
- (void)changeCustomFooterHeight:(NSInteger)height;

#pragma mark - 消息接口

/// 发送消息
/// @param message 消息
- (void)sendMessage:(id)message;

/// 异步发送消息
/// @param message 消息
/// @param completion 完成回调
- (void)sendMessage:(id)message completion:(void(^)(NSError * err))completion;

/// 标记已读
/// @param needSendReceipet 是否需要发送回执告诉对方自己已读
- (void)markRead:(BOOL)needSendReceipet;

- (void)copyText:(id)sender; // 复制消息
- (void)deleteMsg:(id)sender;// 删除消息
- (void)revokeMsg:(id)sender;// 撤回消息
- (void)reportMsg:(id)sender;// 转发消息
- (NSArray<HLIMKitMessageModel *> *)allDatas;

#pragma mark - 操作接口

/// 追加多条消息
/// 直接加在消息列表末尾
/// @param messages 消息集合
- (void)uiAddMessages:(NSArray *)messages;

/// 插入消息
- (void)uiInsertMessages:(NSArray *)messages callback:(void(^ _Nullable )(id data))callback;

- (void)uiClearAllMessages;

/// 删除一条消息
/// @return 被删除的 MessageModel
/// @param message 被删除的消息
- (HLIMKitMessageModel *)uiDeleteMessage:(NIMMessage *)message;

/// 更新消息
/// @param message 要更新的消息
- (HLIMKitMessageModel *)uiUpdateMessage:(NIMMessage *)message;

- (void)uiCheckReceipts:(NSArray<NIMMessageReceipt *> *)receipts;

#pragma mark - 排版

- (void)scrollToBottom:(BOOL)animated;

- (void)setInteractor:(id<HLIMKitSessionInteractor>) interactor;

@end

NS_ASSUME_NONNULL_END
